﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;

namespace Market.DAL
{
    public class Helper
    {
        private static SqlConnection conn = new SqlConnection(@"链接字符串");
        public void Open()
        {
            conn.Open();
        }
        public void Close()
        {
            conn.Close();
        }
        public int ExecuteNonQuery(string sql)
        {
            Open();
            return new SqlCommand(sql,conn).ExecuteNonQuery();
        }
        public object ExecuteScalar(string sql)
        {
            Open();
            return new SqlCommand(sql,conn).ExecuteScalar();
        }
        public SqlDataReader GetReader(string sql)
        {
            Open();
            return new SqlCommand(sql,conn).ExecuteReader();
        }
        public DataTable GetTable(string sql)
        {
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(sql,conn);
            da.Fill(dt);
            return dt;
        }
    }
}
